package com.kx.yooli.kx.wechat.controller.captcha;

import com.kx.yooli.kx.wechat.po.result.AjaxResult;
import com.kx.yooli.kx.wechat.utils.captcha.CaptchaImage;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author john_sqwen-childe.wen
 * date 2024/4/2
 * PROJECT_NAME wechat
 * description create CaptchController by john_sqwen
 * and  value is
 */
@RestController
@RequestMapping("/api/captcha")
public class CaptchaController {
    private final Logger log = LoggerFactory.getLogger(CaptchaController.class);
    @Resource
    private CaptchaImage captchaImage;

    @GetMapping("/render")
    public AjaxResult captchaValue(HttpServletRequest request){
        log.info("captcha sessionId{}",request.getSession().getId());
        return captchaImage.easyGeneratorCode(request);
    }
}
